#include "PublicKey.h"
#include <QtCore>

using namespace kryptos::entities;

namespace kryptos { namespace cryptography
{

PublicKey::PublicKey()
{
}

PublicKey::PublicKey(const QByteArray keyData, const KeyInfo &info)
{
    m_key.clear();
    m_key.append(keyData);
    m_info = info;
}

PublicKey::~PublicKey()
{
}

const QByteArray PublicKey::key() const
{
    return m_key;
}

KeyInfo PublicKey::info() const
{
    return m_info;
}


PublicKey& PublicKey::operator=(const PublicKey &pk)
{
    m_info = pk.m_info;
    m_key.clear();
    m_key.append(pk.key());

    return *this;
}


////////////////////////////////////////////////////////
PrivateKey::PrivateKey()
{
}

PrivateKey::PrivateKey(const QByteArray privatekeyData, const QByteArray publickeyData, const KeyInfo &info)
    : PublicKey(privatekeyData, info)
    , m_publicPart(publickeyData, info)
{
}

PrivateKey::~PrivateKey()
{
}

PublicKey PrivateKey::publicKeyPart() const
{
    return m_publicPart;
}

void PrivateKey::setPassphrase(std::string passphrase)
{
    m_info.setPassphrase(passphrase);
}

PrivateKey& PrivateKey::operator=(const PrivateKey &pk)
{
    m_info = pk.m_info;
    m_key.clear();
    m_key.append(pk.key());
    m_publicPart = pk.publicKeyPart();

    return *this;
}

}}
